home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-27 | 35.9 KB | 1,056 lines |
- @if-using not(ocl-file-autolang)
- @use (ocl-file-autolang)
- ;OCL{{{}}}
- ;OCL{{{ reference decription
- @if-using ( FUN-REFERENCE ) ; 1 ;
- Libary for automatic switching of language and hash-mode. The mode is
- marked with AutoLang or AL in the statusline. Except for
- set-auto-language, which is defined as a macro, all other operations
- are defined as functions.
- @fi
- ;OCL}}}
- ;OCL{{{ reference switching
- @if-using ( FUN-REFERENCE ) ; auto-language switching ; known-endings
- If mode auto-language is active, language and mode hash-shift are
- handled automatically for files using language None, depending on the
- ending of the filename.
-
- The following languages may be switched on automatically:
- @ref-start-tbl Language 8 comment 10 comment 10 # 3 Endings 24
- Occam @@ "--" @@ "" @@ On @@ .ada
- Occam @@ "--" @@ "" @@ Off @@ .occ
- Pascal @@ "(*" @@ "*)" @@ On @@ .p / .pas
- Pascal @@ "(*" @@ "*)" @@ On @@ .mod
- Pascal @@ "(*" @@ "*)" @@ On @@ .h / .hh / .hpp (*)
- C @@ "/*" @@ "*/" @@ On @@ .C / .c / .cc
- C @@ "/*" @@ "*/" @@ On @@ .cpp
- C @@ "/*" @@ "*/" @@ On @@ .l / .y
- C @@ "/*" @@ "*/" @@ On @@ .h / .hh / .hpp (**)
- Script @@ "#" @@ "" @@ Off @@ .sh / rc
- Script @@ "#" @@ "" @@ Off @@ .awk / .pl / .sed
- Script @@ "#" @@ "" @@ Off @@ .m0 .. .m9
- Script @@ "#" @@ "" @@ Off @@ makefile
- Script @@ "#" @@ "" @@ Off @@ Makefile
- Script @@ "#" @@ "" @@ Off @@ MAKEFILE
- Lisp @@ ";" @@ "" @@ On @@ .asm / .s
- Lisp @@ ";" @@ "" @@ On @@ .e
- Lisp @@ ";" @@ "" @@ On @@ .el
- Roff @@ ".\"" @@ "" @@ Off @@ .0 .. .9
- Roff @@ ".\"" @@ "" @@ Off @@ .man
- Roff @@ ".\"" @@ "" @@ Off @@ .me / .ME
- Roff @@ ".\"" @@ "" @@ Off @@ .mm / .MM
- Roff @@ ".\"" @@ "" @@ Off @@ .ms / .MS
- TeX @@ "%" @@ "" @@ Off @@ .tex / .sty / .aux
- User @@ "C" @@ "" @@ Off @@ .F / .FOR / .f / .for
- User @@ "||" @@ "" @@ Off @@ .m
- User @@ "@comment" @@ "" @@ Off @@ .texi
- @ref-end-tbl
- @ref-start-item (*)
- if .p / .pas were used before!
- @ref-end-item
- @ref-start-item (**)
- if .C / .c / .cc / .cpp were used before!
- @ref-end-item
-
- ;OCL{{{ @autolang Known endings
- @ref-start-tbl Endings 60
- .0 .. .9
- .C
- .F
- .ME / .MM / .MS
- .ada / .asm / .aux / .awk
- .c / .cc / .cpp
- .e / .el
- .f / .for
- .h / .hh / .hpp
- .l
- .m / .m0 .. .m9 / .man / .me / .mm / .mod / .ms
- .occ
- .p / .pas / .pl
- .s / .sed / .sh / .sty
- .tex / .texi
- .y
- MAKEFILE
- Makefile
- makefile
- rc
- @ref-end-tbl
- ;OCL}}}
- @fi
- ;OCL}}}
- ;OCL{{{ libs
- @if-using not(ocl-file-delchar) @lib delchar @fi
- ;OCL}}}
- ;OCL{{{ variables
- ( defvar
- ( auto-language
- auto-shift-off
- auto-use-lang
- auto-use-for-h
- auto-lang-change
- auto-used-view
- )
- )
- ;OCL}}}
- ;OCL{{{ modestring
- ( defmodestring AL "AutoLang "AL )
- ;OCL}}}
- ;OCL{{{ set-auto-language
- ;OCL{{{ reference functions
- @if-using ( FUN-REFERENCE ) ; 2 ; set-auto-called
- ;OCL{{{ set-auto-language
- Switch the language and hash-shift mode, depending on the filename.
- If the file is not changed before calling this function, it will be
- left unchanged by this operation.
- ;OCL}}}
- @fi ;( FUN-REFERENCE )
- ;OCL}}}
- ;OCL{{{ auto-lang-switch
- ( demand-load (
- ( deffun auto-lang-switch
- ( set auto-lang-change counter test-file-changed
- set auto-used-view counter test-view
- set auto-use-lang None
- set auto-shift-off false
- ;OCL{{{ get new language
- history-edit-filename file ()
- end-of-line
- backward-character
- if not(test-begin-line)
- ( case
- ;OCL{{{ .[[:digit:]] .m[[:digit:]]
- ( test-char-set digit
- ( backward-character
- case
- ;OCL{{{ . -> .[[:digit:]] -> Roff
- ( test-char ".
- ( set auto-use-lang Roff
- set auto-shift-off true
- )
- )
- ;OCL}}}
- ;OCL{{{ m -> m[[:digit:]]
- ( test-char "m
- ( backward-character
- case
- ;OCL{{{ . -> .m[[:digit:]] -> Script
- ( test-char ".
- ( set auto-use-lang Script
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .ada
- ( test-char "a
- ( backward-character
- case
- ;OCL{{{ d -> da
- ( test-char "d
- ( backward-character
- case
- ;OCL{{{ a -> ada
- ( test-char "a
- ( backward-character
- case
- ;OCL{{{ . -> .ada -> Occam
- ( test-char ".
- ( set auto-use-lang Occam )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .C
- ( test-char "C
- ( backward-character
- case
- ;OCL{{{ . -> .C -> C
- ( test-char ".
- ( set auto-use-lang C
- set auto-use-for-h C
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .c .cc rc .occ
- ( test-char "c
- ( backward-character
- case
- ;OCL{{{ . -> .c -> C
- ( test-char ".
- ( set auto-use-lang C
- set auto-use-for-h C
- )
- )
- ;OCL}}}
- ;OCL{{{ r -> rc -> Script
- ( test-char "r
- ( set auto-use-lang Script
- set auto-shift-off true
- )
- )
- ;OCL}}}
- ;OCL{{{ c -> cc
- ( test-char "c
- ( backward-character
- case
- ;OCL{{{ . -> .cc -> C
- ( test-char ".
- ( set auto-use-lang C
- set auto-use-for-h C
- )
- )
- ;OCL}}}
- ;OCL{{{ o -> occ
- ( test-char "o
- ( backward-character
- case
- ;OCL{{{ . -> .occ -> Occam
- ( test-char ".
- ( set auto-use-lang Occam
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .sed .mod
- ( test-char "d
- ( backward-character
- case
- ;OCL{{{ e -> ed
- ( test-char "e
- ( backward-character
- case
- ;OCL{{{ s -> sed
- ( test-char "s
- ( backward-character
- case
- ;OCL{{{ . -> .sed -> Script
- ( test-char ".
- ( set auto-use-lang Script
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ o -> od
- ( test-char "o
- ( backward-character
- case
- ;OCL{{{ m -> mod
- ( test-char "m
- ( backward-character
- case
- ;OCL{{{ . -> .mod -> Pascal
- ( test-char ".
- ( set auto-use-lang Pascal )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ MAKEFILE MAKEFILE .ME
- ( test-char "E
- ( backward-character
- case
- ;OCL{{{ M -> ME
- ( test-char "M
- ( backward-character
- case
- ;OCL{{{ . -> .ME -> roff
- ( test-char ".
- ( set auto-use-lang Roff
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ L -> LE
- ( test-char "L
- ( backward-character
- backward-character
- backward-character
- backward-character
- backward-character
- backward-character
- if test-str "MAKEFI
- ( set auto-use-lang Script
- set auto-shift-off true
- )
- fi
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ makefile Makefile .e .me
- ( test-char "e
- ( backward-character
- case
- ;OCL{{{ . -> .e -> Lisp
- ( test-char ".
- ( set auto-use-lang Lisp )
- )
- ;OCL}}}
- ;OCL{{{ m -> me
- ( test-char "m
- ( backward-character
- case
- ;OCL{{{ . -> .me -> roff
- ( test-char ".
- ( set auto-use-lang Roff
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ l -> le
- ( test-char "l
- ( backward-character
- backward-character
- backward-character
- backward-character
- backward-character
- if test-str "akefi
- ( backward-character
- if or(test-char "m test-char "M)
- ( set auto-use-lang Script
- set auto-shift-off true
- )
- fi
- )
- fi
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .F
- ( test-char "F
- ( backward-character
- case
- ;OCL{{{ . -> .F -> User C
- ( test-char ".
- ( set auto-use-lang -1
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .f
- ( test-char "f
- ( backward-character
- case
- ;OCL{{{ . -> .f -> User C
- ( test-char ".
- ( set auto-use-lang -1
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .h .hh .sh
- ( test-char "h
- ( backward-character
- case
- ;OCL{{{ . -> .h -> C or Pascal or no change
- ( test-char ".
- ( if auto-use-for-h
- ( set auto-use-lang auto-use-for-h )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ h -> hh
- ( test-char "h
- ( backward-character
- case
- ;OCL{{{ . -> .hh -> C or Pascal or no change
- ( test-char ".
- ( if auto-use-for-h
- ( set auto-use-lang auto-use-for-h )
- fi
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ s -> sh
- ( test-char "s
- ( backward-character
- case
- ;OCL{{{ . -> .sh -> Script
- ( test-char ".
- ( set auto-use-lang Script
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .texi
- ( test-char "i
- ( backward-character
- case
- ;OCL{{{ x -> xi
- ( test-char "x
- ( backward-character
- case
- ;OCL{{{ e -> exi
- ( test-char "e
- ( backward-character
- case
- ;OCL{{{ t -> texi
- ( test-char "t
- ( backward-character
- case
- ;OCL{{{ . -> .texi -> U @comment
- ( test-char ".
- ( set auto-use-lang -3
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .awk
- ( test-char "k
- ( backward-character
- case
- ;OCL{{{ w -> wk
- ( test-char "w
- ( backward-character
- case
- ;OCL{{{ a -> awk
- ( test-char "a
- ( backward-character
- case
- ;OCL{{{ . -> .awk -> Script
- ( test-char ".
- ( set auto-use-lang Script
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .l .pl .el
- ( test-char "l
- ( backward-character
- case
- ;OCL{{{ p -> pl
- ( test-char "p
- ( backward-character
- case
- ;OCL{{{ . -> .pl -> Script
- ( test-char ".
- ( set auto-use-lang Script
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ e -> el
- ( test-char "e
- ( backward-character
- case
- ;OCL{{{ . -> .el -> Lisp
- ( test-char ".
- ( set auto-use-lang Lisp )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ . -> .l -> C
- ( test-char ".
- ( set auto-use-lang Script )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .MM
- ( test-char "M
- ( backward-character
- case
- ;OCL{{{ M -> MM
- ( test-char "M
- ( backward-character
- case
- ;OCL{{{ . -> .MM -> roff
- ( test-char ".
- ( set auto-use-lang Roff
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .m .mm .asm
- ( test-char "m
- ( backward-character
- case
- ;OCL{{{ . -> .m -> U ||
- ( test-char ".
- ( set auto-use-lang -2
- set auto-shift-off true
- )
- )
- ;OCL}}}
- ;OCL{{{ m -> mm
- ( test-char "m
- ( backward-character
- case
- ;OCL{{{ . -> .mm -> Roff
- ( test-char ".
- ( set auto-use-lang Roff
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ s -> sm
- ( test-char "s
- ( backward-character
- case
- ;OCL{{{ a -> asm
- ( test-char "a
- ( backward-character
- case
- ;OCL{{{ . -> .asm -> Lisp
- ( test-char ".
- ( set auto-use-lang Lisp )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .man
- ( test-char "n
- ( backward-character
- case
- ;OCL{{{ a -> an
- ( test-char "a
- ( backward-character
- case
- ;OCL{{{ m -> man
- ( test-char "m
- ( backward-character
- case
- ;OCL{{{ . -> .man -> Roff
- ( test-char ".
- ( set auto-use-lang Roff
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .p .cpp .hpp
- ( test-char "p
- ( backward-character
- case
- ;OCL{{{ . -> .p -> Pascal
- ( test-char ".
- ( set auto-use-lang Pascal
- set auto-use-for-h Pascal
- )
- )
- ;OCL}}}
- ;OCL{{{ p -> pp
- ( test-char "p
- ( backward-character
- case
- ;OCL{{{ c ->cpp
- ( test-char "c
- ( backward-character
- case
- ;OCL{{{ . -> .cpp -> C
- ( test-char ".
- ( set auto-use-lang C
- set auto-use-for-h C
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ h ->hpp
- ( test-char "h
- ( backward-character
- case
- ;OCL{{{ . -> .hpp -> C or Pascal or no change
- ( test-char ".
- ( if auto-use-for-h
- ( set auto-use-lang auto-use-for-h )
- fi
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .FOR
- ( test-char "R
- ( backward-character
- case
- ;OCL{{{ O -> OR
- ( test-char "O
- ( backward-character
- case
- ;OCL{{{ F -> FOR
- ( test-char "F
- ( backward-character
- case
- ;OCL{{{ . -> .FOR -> User C
- ( test-char ".
- ( set auto-use-lang -1
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .for
- ( test-char "r
- ( backward-character
- case
- ;OCL{{{ o -> or
- ( test-char "o
- ( backward-character
- case
- ;OCL{{{ f -> for
- ( test-char "f
- ( backward-character
- case
- ;OCL{{{ . -> .for -> User C
- ( test-char ".
- ( set auto-use-lang -1
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .MS
- ( test-char "S
- ( backward-character
- case
- ;OCL{{{ M -> MS
- ( test-char "M
- ( backward-character
- case
- ;OCL{{{ . -> .MS -> roff
- ( test-char ".
- ( set auto-use-lang Roff
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .ms .s
- ( test-char "s
- ( backward-character
- case
- ;OCL{{{ m -> ms
- ( test-char "m
- ( backward-character
- case
- ;OCL{{{ . -> .ms -> roff
- ( test-char ".
- ( set auto-use-lang Roff
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ . -> .s -> Lisp
- ( test-char ".
- ( set auto-use-lang Lisp )
- )
- ;OCL}}}
- ;OCL{{{ a -> as
- ( test-char "a
- ( backward-character
- case
- ;OCL{{{ p -> pas
- ( test-char ".
- ( backward-character
- case
- ;OCL{{{ . -> .pas -> Pascal
- ( test-char ".
- ( set auto-use-lang Pascal
- set auto-use-for-h Pascal
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .y .sty
- ( test-char "y
- ( backward-character
- case
- ;OCL{{{ . -> .y -> C
- ( test-char ".
- ( set auto-use-lang C )
- )
- ;OCL}}}
- ;OCL{{{ t -> ty
- ( test-char "t
- ( backward-character
- case
- ;OCL{{{ s -> sty
- ( test-char "s
- ( backward-character
- case
- ;OCL{{{ . -> .sty -> TeX
- ( test-char ".
- ( set auto-use-lang TeX
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ .tex .aux
- ( test-char "x
- ( backward-character
- case
- ;OCL{{{ e -> ex
- ( test-char "e
- ( backward-character
- case
- ;OCL{{{ t -> tex
- ( test-char "t
- ( backward-character
- case
- ;OCL{{{ . -> .tex -> TeX
- ( test-char ".
- ( set auto-use-lang TeX
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- ;OCL{{{ u -> ux
- ( test-char "u
- ( backward-character
- case
- ;OCL{{{ a -> aux
- ( test-char "a
- ( backward-character
- case
- ;OCL{{{ . -> .aux -> TeX
- ( test-char ".
- ( set auto-use-lang TeX
- set auto-shift-off true
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- )
- ;OCL}}}
- esac
- )
- fi
- beginning-of-line
- delete-to-end-of-line
- newline-and-indent
- ;OCL}}}
- if auto-used-view ( delete-mode-view ) fi
- ;OCL{{{ set shift and language
- if auto-shift-off ( delete-mode-hash-shift ) fi
- case
- ;OCL{{{ >0==auto-use-lang
- ( >(auto-use-lang 0)
- ( set-language insert-ascii auto-use-lang
- if or(=(auto-use-lang C) =(auto-use-lang Pascal))
- ( add-mode-hash-shift )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ -1==C
- ( =(auto-use-lang -1)
- ( set-language User "C newline-and-indent newline-and-indent )
- )
- ;OCL}}}
- ;OCL{{{ -2==||
- ( =(auto-use-lang -2)
- ( set-language User "| "| newline-and-indent newline-and-indent )
- )
- ;OCL}}}
- ;OCL{{{ -3==@comment
- ( =(auto-use-lang -3)
- ( set-language User "@ "comment newline-and-indent newline-and-indent )
- )
- ;OCL}}}
- esac
- ;OCL}}}
- if auto-used-view ( add-mode-view ) fi
- if not(auto-lang-change)
- ( set-file-unchanged )
- fi
- )
- )
- ))
- ;OCL}}}
- ( defmac set-auto-language
- ( if and(auto-language test-language None =(file-type 0))
- ( auto-lang-switch )
- fi
- )
- )
- ;OCL}}}
- ;OCL{{{ add-mode-auto-language
- ;OCL{{{ reference
- @if-using ( FUN-REFERENCE ) ; 2 ; add-auto-called
- ;OCL{{{ add-mode-auto-language
- Switch on auto-language mode
- ;OCL}}}
- @fi ;( FUN-REFERENCE )
- ;OCL}}}
- ( deffun add-mode-auto-language
- ( set auto-language true
- set-user-mode AL
- )
- )
- ;OCL}}}
- ;OCL{{{ delete-mode-auto-language
- ;OCL{{{ reference functions
- @if-using ( FUN-REFERENCE ) ; 2 ; del-auto-called
- ;OCL{{{ delete-mode-auto-language
- Switch off auto-language mode
- ;OCL}}}
- @fi ;( FUN-REFERENCE )
- ;OCL}}}
- ( deffun delete-mode-auto-language
- ( set auto-language false
- reset-user-mode AL
- load-function not(auto-lang-switch)
- )
- )
- ;OCL}}}
- ;OCL{{{ reference hooks
- @if-using ( FUN-REFERENCE ) ; 3 ;
- The libary functions are marked as demand-loading.
- @fi
- ;OCL}}}
- ;OCL{{{ undeclares
- ( undeclare
- ( auto-shift-off
- auto-use-lang
- auto-use-for-h
- auto-lang-change
- auto-used-view
- auto-lang-switch
- )
- )
- ;OCL}}}
- @fi
-